﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.EnterpriseCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.EnterpriseHandler
{
    public class EnterpriseDelCommandHandler : IRequestHandler<EnterpriseDelCommand, Results<int>>
    {

        private readonly IEnterpriseService enterpriseService;
        IMapper mapper;

        public EnterpriseDelCommandHandler(IEnterpriseService enterpriseService, IMapper mapper)
        {
            this.enterpriseService = enterpriseService;
            this.mapper = mapper;
        }

        /// <summary>
        /// 删除企业
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(EnterpriseDelCommand request, CancellationToken cancellationToken)
        {
            var list = enterpriseService.DeleteEnterprises(request.EnterpriseId);
            return Results<int>.DataResult(list);
        }
    }
}
